﻿using System.Web.Mvc;
using Abmemunit.Services.Users;

namespace Abmemunit.Web.Controllers
{
    public class HomeController : Controller
    {
        //
        // GET: /Home/
        readonly IUserService _userService;

        public HomeController(IUserService userService)
        {
            _userService = userService;

        }

        public ActionResult Index()
        {
            bool isAdminUser = false;

            if (!string.IsNullOrEmpty(this.HttpContext.User.Identity.Name))
            {
                var dbUser = _userService.GetUserByName(HttpContext.User.Identity.Name);
                if (dbUser != null && dbUser.IsAdminAccount == true)
                {
                    isAdminUser = true;
                }
            }
            
            return View(isAdminUser);
        }

    }
}
